package xyz.tanxiao.links.common.request;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;

/**
 * 长链接转短链接请求参数
 *
 * @author 万成波
 * @email 2300064869@qq.com
 * @createTime 2023-06-10 21:03:38 星期六
 */
@Getter
@Setter
public class ToShortLinkRequest {

	/**
	 * 原始长链接URL
	 */
	@NotBlank(message = "原始链接不能为空")
	@Length(max = 400, message = "原始链接长度过长")
	private String sourceUrl;

	/**
	 * 短链接启用时间
	 */
	@DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
	@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss", timezone = "GMT+8")
	private LocalDateTime enableTime;

	/**
	 * 短链接禁用时间
	 */
	@DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
	@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss", timezone = "GMT+8")
	private LocalDateTime disableTime;

	/**
	 * 短链接允许访问次数
	 */
	@Min(value = 0, message = "短链访问次数设置错误")
	private Long allowTotal;

	/**
	 * 短链接访问密码
	 */
	@Length(max = 20, message = "短链访问密码长度设置错误")
	private String accessPassword;

}